Add share-ttl: auto-expire shares after configurable timeout#4
Merged
Conversation
Shared sessions now expire automatically after share-ttl seconds (default: 3600 / 1 hour). Running `ds --share` on an already-shared session resets the timer. Set share-ttl = 0 to disable. Implementation: - New config key share-ttl / env DS_UPTERM_SHARE_TTL - _upterm_start_ttl_watcher: spawns a detached background process (via setsid or plain subshell) that sleeps for TTL seconds then calls `ds --unshare`; saves watcher PID to .upterm.ttl.pid - _upterm_cancel_ttl_watcher: kills watcher + sleep child (SIGTERM process group), removes pid file - _share_start: starts watcher on successful share; resets timer (cancels old watcher, starts new) when re-sharing same session - _share_stop: cancels watcher before cleanup - README + examples/share-upterm.conf updated
3ef9430 to
8ed848d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Shared sessions now expire automatically after a configurable timeout (
share-ttl, default: 1 hour). Runningds --shareon an already-shared session resets the timer. Setshare-ttl = 0to disable.Behavior
ds --share: starts a background watcher that firesds --unshareaftershare-ttlseconds; printsds: share will auto-expire in 3600s (run 'ds --share' to reset)ds --sharewhen already sharing: cancels the old watcher, starts a new one; printsds: already sharing session '..' (TTL reset to 3600s)ds --unshare/ kill / killall: cancels watcher as part of cleanupImplementation
share-ttl/ envDS_UPTERM_SHARE_TTL(default:3600)_upterm_ttl_pid_file: state file for watcher PID (.upterm.ttl.pid)_upterm_start_ttl_watcher: spawns detached background process viasetsid(or plain subshell fallback) —sleep TTL && ds --unshare SESSION; saves PID for later cancellation_upterm_cancel_ttl_watcher: SIGTERMs the process group to kill both the shell and thesleepchild_share_start_successhelper: consolidates the three success paths in_share_startto avoid repeating watcher-start logic_share_stop: calls_upterm_cancel_ttl_watcherbefore cleanupshare-ttlrow in config table + "Share TTL" sectionexamples/share-upterm.conf:share-ttl=3600added (commented out)Notes
ds_binis resolved viacommand -v dsbefore forking, withprintf %qescaping for safetyds --unshareis called manually before the timer fires,_share_stopcancels the watcher cleanly